package com.cskaoyan.controller.comment;

import com.cskaoyan.bean.MallComment;
import com.cskaoyan.model.bo.comment.CommentPageBo;
import com.cskaoyan.model.vo.BaseRespVo;
import com.cskaoyan.model.vo.comment.commentlist.CommentPageVO;
import com.cskaoyan.service.comment.CommentService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: project-market
 * @description:
 * @author: Jesson Guo
 * @create: 2021-12-01 21:54
 **/
@RequestMapping("admin/comment")
@RestController
public class CommentController {
    @Autowired
    CommentService commentService;


//    评论搜寻和展示   by GJC

    @RequiresPermissions("admin:comment:list")
    @GetMapping("list")
    public BaseRespVo allCommentList(CommentPageBo commentPageBo) {
        CommentPageVO commentPageVO = commentService.allCommentList(commentPageBo);
        return BaseRespVo.ok(commentPageVO);
    }

    @RequiresPermissions("admin:comment:delete")
    @PostMapping("delete")
    public BaseRespVo deleteComment(@RequestBody MallComment mallComment){
        int code = commentService.deleteComment(mallComment);
        if (code==200)return BaseRespVo.ok();
        else return BaseRespVo.manual(611,"商品已经被其他管理员删除",null);
    }
}
